package com.visceb.backstage.controller;;
import com.visceb.backstage.dao.emailRepository;
import com.visceb.backstage.dao.loginRepository;
import com.visceb.backstage.entity.email;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("email")
@CrossOrigin()
public class emailController {
    @Autowired
    private emailRepository emailrepository;

    @RequestMapping(value ="/emailByWordsLike", method = RequestMethod.GET)
    @ResponseBody
    public List<email> findWords(String word, String startTime, String endTime) {
//        LocalDate startDate = LocalDate.parse(startTime);
//        LocalDate endDate = LocalDate.parse(endTime);
//        return emailrepository.findAllByWordsLike(word, startDate, endDate);
        return emailrepository.findAllBySubjectLike("%"+ word +"%");
    }
}
